{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Set up data directories prior to using fastai libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python Version: 3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12) \n",
      "[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]\n"
     ]
    }
   ],
   "source": [
    "# check what version of Python I'm using\n",
    "import sys\n",
    "print(\"Python Version:\", sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# this is my path where my CODE is\n",
    "PATH = \"/Users/reshamashaikh/ds/my_repos/fastai_deeplearn_part1/code/\"\n",
    "PATH_CODE = \"/Users/reshamashaikh/ds/my_repos/fastai_deeplearn_part1/code/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# create data directory if it doesn't exist\n",
    "# remember to comment out once you've created it, so you don't run this cell again\n",
    "# os.makedirs(PATH_CODE+'data', exist_ok=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# create directory for dogscats project; only have to do this once\n",
    "#os.makedirs(PATH_CODE+'data/dogscats', exist_ok=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# create directory for dogscats project; only have to do this once\n",
    "#os.makedirs(PATH_CODE'data/dogscats/valid', exist_ok=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Download data from Kaggle\n",
    "can also download data into a temp folder and then move files to /data/dogscats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# go to this directory in terminal\n",
    "# !ls {PATH_CODE}data/dogscats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#!kg config -g -u 'reshamashaikh' -p 'xxx' -c dogs-vs-cats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#!kg download"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/Users/reshamashaikh/ds/my_repos/fastai_deeplearn_part1/code\r\n"
     ]
    }
   ],
   "source": [
    "!pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 40\r\n",
      "-rw-r--r--  1 reshamashaikh  staff  19956 Nov 18 17:23 a_dogscats_setup_data.ipynb\r\n",
      "drwxr-xr-x  4 reshamashaikh  staff    136 Nov 18 17:22 \u001b[34mdata\u001b[m\u001b[m\r\n"
     ]
    }
   ],
   "source": [
    "!ls -l {PATH_CODE}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 0\r\n",
      "drwxr-xr-x  6 reshamashaikh  staff  204 Nov 18 17:22 \u001b[34mdogscats\u001b[m\u001b[m\r\n"
     ]
    }
   ],
   "source": [
    "!ls -l {PATH_CODE}data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 0\r\n",
      "drwxr-xr-x  12502 reshamashaikh  staff  425068 Sep 20  2013 \u001b[34mtest1\u001b[m\u001b[m\r\n",
      "drwxr-xr-x      5 reshamashaikh  staff     170 Nov 18 15:33 \u001b[34mtrain\u001b[m\u001b[m\r\n",
      "drwxr-xr-x      5 reshamashaikh  staff     170 Nov 18 15:53 \u001b[34mvalid\u001b[m\u001b[m\r\n"
     ]
    }
   ],
   "source": [
    "!ls -l {PATH_CODE}data/dogscats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34;40m../\u001b[00m\n",
      "├── \u001b[34;40mcode\u001b[00m\n",
      "│   └── \u001b[34;40mdata\u001b[00m\n",
      "│       └── \u001b[34;40mdogscats\u001b[00m\n",
      "│           ├── \u001b[34;40mtest1\u001b[00m\n",
      "│           ├── \u001b[34;40mtrain\u001b[00m\n",
      "│           │   ├── \u001b[34;40mcats\u001b[00m\n",
      "│           │   └── \u001b[34;40mdogs\u001b[00m\n",
      "│           └── \u001b[34;40mvalid\u001b[00m\n",
      "│               ├── \u001b[34;40mcats\u001b[00m\n",
      "│               └── \u001b[34;40mdogs\u001b[00m\n",
      "├── \u001b[34;40mimages\u001b[00m\n",
      "├── \u001b[34;40mlessons\u001b[00m\n",
      "└── \u001b[34;40mtools\u001b[00m\n",
      "\n",
      "13 directories\n"
     ]
    }
   ],
   "source": [
    "!tree ../ -d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# to install on Linux\n",
    "# sudo apt install unzip"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#!unzip -q {PATH_CODE}data/dogscats/train.zip"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Example of printout when not using <kbd> -q </kbd> flag\n",
    "```bash\n",
    "Archive:  /Users/reshamashaikh/ds/data/dogscats/train.zip\n",
    "   creating: train/\n",
    "  inflating: train/cat.0.jpg         \n",
    "  inflating: train/cat.1.jpg         \n",
    "  inflating: train/cat.10.jpg        \n",
    "  inflating: train/cat.100.jpg \n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# run at terminal, might be faster\n",
    "#!unzip -q {PATH}data/dogscats/test1.zip"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### move **dogs** photos to separate directory\n",
    "```bash\n",
    "mv dog.* dogs\n",
    "mv dog.9* dogs\n",
    "mv dog.8* dogs\n",
    "mv dog.* dogs\n",
    "ls dogs/ | wc -l\n",
    "```\n",
    "#### move **cats** photos to separate directory\n",
    "```bash\n",
    "mv cat.* cats\n",
    "mv cat.9* cats\n",
    "mv cat.8* cats\n",
    "mv cat.* cats\n",
    "ls cats/ | wc -l\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   12500\r\n"
     ]
    }
   ],
   "source": [
    "!ls train/dogs/ | wc -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   12500\r\n"
     ]
    }
   ],
   "source": [
    "!ls train/cats/ | wc -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   12500\r\n"
     ]
    }
   ],
   "source": [
    "# see how many files are in test folder\n",
    "! ls test1/ | wc -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# want to create a \"valid\" directory for validation.  \n",
    "# Advice from Jeremy:  \n",
    "#    separate TEST data into VALIDATION TASK: move 1000 each dogs / cats into valid\n",
    "# only do this once and then comment out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#os.makedirs(PATH_CODE+'valid', exist_ok=True)\n",
    "#os.makedirs(PATH_CODE+'valid/cats', exist_ok=True)\n",
    "#os.makedirs(PATH_CODE+'valid/dogs', exist_ok=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 0\r\n",
      "drwxr-xr-x  2 reshamashaikh  staff  68 Nov 18 15:42 \u001b[34mcats\u001b[m\u001b[m\r\n",
      "drwxr-xr-x  2 reshamashaikh  staff  68 Nov 18 15:25 \u001b[34mdogs\u001b[m\u001b[m\r\n"
     ]
    }
   ],
   "source": [
    "!ls -l {PATH_CODE}valid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   12500\n",
      "   12500\n",
      "   12500\n",
      "       0\n",
      "       0\n"
     ]
    }
   ],
   "source": [
    "# before splitting data\n",
    "!ls train/dogs/ | wc -l\n",
    "!ls train/cats/ | wc -l\n",
    "\n",
    "!ls test1/| wc -l\n",
    "\n",
    "!ls valid/dogs/ | wc -l\n",
    "!ls valid/cats/ | wc -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/Users/reshamashaikh/ds/my_repos/fastai_deeplearn_part1/code\r\n"
     ]
    }
   ],
   "source": [
    "!pwd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 40\r\n",
      "-rw-r--r--      1 reshamashaikh  staff   19159 Nov 18 17:13 a_setup_data.ipynb\r\n",
      "drwxr-xr-x  12502 reshamashaikh  staff  425068 Sep 20  2013 \u001b[34mtest1\u001b[m\u001b[m\r\n",
      "drwxr-xr-x      5 reshamashaikh  staff     170 Nov 18 15:33 \u001b[34mtrain\u001b[m\u001b[m\r\n",
      "drwxr-xr-x      5 reshamashaikh  staff     170 Nov 18 15:53 \u001b[34mvalid\u001b[m\u001b[m\r\n"
     ]
    }
   ],
   "source": [
    "!ls -l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Updating Homebrew...\n",
      "\u001b[34m==>\u001b[0m \u001b[1mAuto-updated Homebrew!\u001b[0m\n",
      "Updated 1 tap (caskroom/cask).\n",
      "No changes to formulae.\n",
      "\n",
      "\u001b[34m==>\u001b[0m \u001b[1mDownloading https://homebrew.bintray.com/bottles/coreutils-8.28_1.el_capitan\u001b[0m\n",
      "######################################################################## 100.0%\n",
      "\u001b[34m==>\u001b[0m \u001b[1mPouring coreutils-8.28_1.el_capitan.bottle.tar.gz\u001b[0m\n",
      "\u001b[34m==>\u001b[0m \u001b[1mCaveats\u001b[0m\n",
      "All commands have been installed with the prefix 'g'.\n",
      "\n",
      "If you really need to use these commands with their normal names, you\n",
      "can add a \"gnubin\" directory to your PATH from your bashrc like:\n",
      "\n",
      "    PATH=\"/usr/local/opt/coreutils/libexec/gnubin:$PATH\"\n",
      "\n",
      "Additionally, you can access their man pages with normal names if you add\n",
      "the \"gnuman\" directory to your MANPATH from your bashrc as well:\n",
      "\n",
      "    MANPATH=\"/usr/local/opt/coreutils/libexec/gnuman:$MANPATH\"\n",
      "\n",
      "\u001b[34m==>\u001b[0m \u001b[1mSummary\u001b[0m\n",
      "🍺  /usr/local/Cellar/coreutils/8.28_1: 430 files, 9.1MB\n"
     ]
    }
   ],
   "source": [
    "# need to install it on Mac\n",
    "#!brew install coreutils\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# want to move 1000 images from train folder to valid folder\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/bin/sh: shuf: command not found\r\n",
      "xargs: illegal option -- i\r\n",
      "usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\r\n",
      "             [-L number] [-n number [-x]] [-P maxprocs] [-s size]\r\n",
      "             [utility [argument ...]]\r\n"
     ]
    }
   ],
   "source": [
    "!shuf -n 100 -e train/cats | xargs -i mv valid/cats\n",
    "#shuf -n 100 -e {PATH_CODE}/train/dogs | xargs -i mv {PATH_CODE}/valid/dogs\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# use this directory to store models\n",
    "# os.makedirs(PATH+'/data/dogscats/models', exist_ok=True)\n",
    "\n",
    "# use this directory for small sub-sample; makes it easier to run test models\n",
    "# COPY 100 pictures from train directory to \"sample\"\n",
    "#os.makedirs(PATH+'/data/dogscats/sample', exist_ok=True)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Workflow\n",
    "1.  Put images into folders with their labels\n",
    "2.  Run image classifier"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Symbolic Links\n",
    "Here’s an example. Let’s say you wanted to create a symbolic link in your Desktop folder that points to your Downloads folder. You’d run the following command:\n",
    "\n",
    "<kbd> ln -s /Users/name/Downloads /Users/name/Desktop </kbd>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Creating a Subset of Data for Initial Network Building\n",
    "In your notebook, change the PATH to PATH = \"data/dogscats_sample/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#!mkdir -p data/dogscats_sample/{valid,train}/{cats,dogs}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34;40m../\u001b[00m\n",
      "├── \u001b[34;40mcode\u001b[00m\n",
      "│   └── \u001b[34;40mdata\u001b[00m\n",
      "│       ├── \u001b[34;40mdogscats\u001b[00m\n",
      "│       │   ├── \u001b[34;40mtest1\u001b[00m\n",
      "│       │   ├── \u001b[34;40mtrain\u001b[00m\n",
      "│       │   │   ├── \u001b[34;40mcats\u001b[00m\n",
      "│       │   │   └── \u001b[34;40mdogs\u001b[00m\n",
      "│       │   └── \u001b[34;40mvalid\u001b[00m\n",
      "│       │       ├── \u001b[34;40mcats\u001b[00m\n",
      "│       │       └── \u001b[34;40mdogs\u001b[00m\n",
      "│       └── \u001b[34;40mdogscats_sample\u001b[00m\n",
      "│           ├── \u001b[34;40mtrain\u001b[00m\n",
      "│           │   ├── \u001b[34;40mcats\u001b[00m\n",
      "│           │   └── \u001b[34;40mdogs\u001b[00m\n",
      "│           └── \u001b[34;40mvalid\u001b[00m\n",
      "│               ├── \u001b[34;40mcats\u001b[00m\n",
      "│               └── \u001b[34;40mdogs\u001b[00m\n",
      "├── \u001b[34;40mimages\u001b[00m\n",
      "├── \u001b[34;40mlessons\u001b[00m\n",
      "└── \u001b[34;40mtools\u001b[00m\n",
      "\n",
      "20 directories\n"
     ]
    }
   ],
   "source": [
    "!tree ../ -d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#!gshuf -n 200 -e data/dogscats/train/cats | xargs -i cp {} data/dogscats_sample/train/cats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# set sample data\n",
    "\n",
    "shuf -n 200 -e data/dogscats/train/cats | xargs -i cp {} data/dogscats_sample/train/cats\n",
    "shuf -n 200 -e data/dogscats/train/cats/* | xargs -i cp {} data/dogscats_sample/train/cats\n",
    "shuf -n 200 -e data/dogscats/train/dogs/* | xargs -i cp {} data/dogscats_sample/train/dogs\n",
    "shuf -n 100 -e data/dogscats/valid/cats/* | xargs -i cp {} data/dogscats_sample/valid/cats\n",
    "shuf -n 100 -e data/dogscats/valid/dogs/* | xargs -i cp {} data/dogscats_sample/valid/dogs\n",
    "\n",
    "\n",
    "In your notebook, change the PATH to PATH = \"data/dogscats_sample/\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#files = !ls {PATH}valid/cats | head\n",
    "#files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['cat.0.jpg',\n",
       " 'cat.1.jpg',\n",
       " 'cat.10.jpg',\n",
       " 'cat.100.jpg',\n",
       " 'cat.1000.jpg',\n",
       " 'cat.10000.jpg',\n",
       " 'cat.10001.jpg',\n",
       " 'cat.10002.jpg',\n",
       " 'cat.10003.jpg',\n",
       " 'cat.10004.jpg']"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "files = !ls {PATH_CODE}data/dogscats/train/cats | head\n",
    "files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "ImportError",
     "evalue": "No module named 'fastai'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-108-b3b9f92d22dc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0;31m# This file contains all the main external libs we'll use\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mfastai\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimports\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mImportError\u001b[0m: No module named 'fastai'"
     ]
    }
   ],
   "source": [
    "# This file contains all the main external libs we'll use\n",
    "from fastai.imports import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'plt' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-107-2a34a41ce5e8>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m# example of one of the cats\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mimg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0mfiles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimshow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'plt' is not defined"
     ]
    }
   ],
   "source": [
    "# example of one of the cats\n",
    "img = plt.imread({files[0]})\n",
    "plt.imshow(img);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
